package com.zft.userwalletmanager.infrastructure.common.enums;

import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
public enum WalletStatusEnums {
    ON("ON","正常"),
    FROZEN("FROZEN","冻结");
    private String code;
    private String message;

    WalletStatusEnums(String code, String message) {
        this.code = code;
        this.message = message;
    }
    public static WalletStatusEnums getOfCode(String code) {
        if (StringUtils.isBlank(code)) {
            throw new IllegalArgumentException("code is blank");
        }
        WalletStatusEnums[] values = WalletStatusEnums.values();
        for (WalletStatusEnums value : values) {
            if (value.getCode().equals(code)) {
                return value;
            }
        }
        throw new IllegalArgumentException("no find WalletStatusEnums must is ON or FROZEN");
    }
    public static WalletStatusEnums getOfMessage(String message) {
        if (StringUtils.isBlank(message)) {
            throw new IllegalArgumentException("message is blank");
        }
        WalletStatusEnums[] values = WalletStatusEnums.values();
        for (WalletStatusEnums value : values) {
            if (value.getMessage().equals(message)) {
                return value;
            }
        }
        throw new IllegalArgumentException("no find WalletStatusEnums must is '正常' or '冻结'");
    }
}
